﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LDSP.BRL;
using BYFW.Encrypt;

namespace LDSP.UI
{
    public partial class DownloadHelp : BRL.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    this.CheckQS();
                }
                if (this.RB())
                {
                    this.StartDownload(Codification.FileName, Codification.GetDownloadFileFullName());
                }
            }
            catch (Exception ex)
            {
                this.HandlerException(ex);
            }            
        }
        protected Codification m_codification = null;

        protected int LastID
        {
            get { return this.GetVSInt("LastID"); }
            set
            {
                this.SetVS("LastID", value);
                m_codification = null;
            }
        }
        protected Codification Codification
        {
            get
            {
                if (m_codification == null)
                {
                    m_codification = new Codification();
                    if (LastID != 0)
                    {
                        m_codification.GetProperties(LastID);
                    }
                }
                return m_codification;
            }
        }

        public override void RedirectBefore()
        {
            
        }

        protected void CheckQS()
        {
            try
            {
                LastID = this.GetInt(Base64.Decrypt(this.Request.QueryString["cid"]));
            }
            catch { }
        }
        protected bool RB()
        {
            if (LoginAdmin != null)
            {
                return true;
            }
            if (LoginUser != null)
            {
                if (LoginUser.EnterpriseID != Codification.EnterpriseID)
                {
                    this.JSAlert("您没有权限下载！");
                    return false;
                }
                return true;
            }
            return false;
        }
    }
}